package com.marisfrolg.gateway.service.impl;

import com.marisfrolg.gateway.entity.TUserRole;
import com.marisfrolg.gateway.mapper.TUserRoleMapper;
import com.marisfrolg.gateway.service.TUserRoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lgg
 * @since 2023-01-05
 */
@Service
public class TUserRoleServiceImpl extends ServiceImpl<TUserRoleMapper, TUserRole> implements TUserRoleService {

    @Autowired
    private TUserRoleMapper userRoleMapper;

    @Override
    public List<String> getPermissionsByUsername(String username) {
        List<String> roles = getRolesByUsername(username);
        return userRoleMapper.getPermissionsByRoles(roles);
    }

    @Override
    public List<String> getRolesByUsername(String username) {
        return userRoleMapper.getRolesByUsername(username);
    }
}
